<template>
    <div class="Question">
        <pre-image></pre-image>
        <Ope
            searchFun='searchQuestion'
            @searchQuestion="searchQuestion"
            :allSearchKind="allSearchKind"
            :ifSearch="true"
            :ifNew="true"
            newFun="refresh"
            @refresh="refresh"
        ></Ope>
        <Table
            ref="table"
            class="table"
            :tableData="question"
            @showDialog="lookQuestion"
            @delQuestion="delQuestion"
        ></Table>
        <el-pagination
        :current-page.sync="nowPage"
        @current-change="choosePage"
        :page-size="onePageDataNum"
        style="margin-top: .4rem"
        background
        layout="prev, pager, next"
        :total="dataTotal">
        </el-pagination>
        <Dialog 
            ref="dialog"
            @confirmEdit="updateQuestion" 
        ></Dialog>
    </div>
</template>

<script>
import Dialog from './Dialog'
import Table from './Table'
import Ope from 'template/Ope'
import PreImage from 'template/PreImage'
import DialogAdd from './DialogAdd'
import methods from './methods.js'
import axios from 'axios'

export default {
    name: 'Question',
    components: {
        Dialog,
        Table,
        Ope,
        PreImage,
        DialogAdd
    },
    watch: {
        '$route' (to, from) {
            this.listenRoute();
        }
    },
    mounted () {
        this.$router.push('question');
        this.listenRoute();
    },
    data() {
        return {
            nowPage: 1,
            keyName: '',
            keyWord: '',
            question: [],
            dataTotal: 1000,
            onePageDataNum: 2,
            pageIndex: 1,
            allSearchKind: [
                {
                    label: '所属类别',
                    value: 'kindName'
                },
                {
                    label: '用户名',
                    value: 'user'
                },
                {
                    label: '支付价格',
                    value: 'payPrice'
                },
                {
                    label: '是否匿名',
                    value: 'isAnonymous'
                },
                {
                    label: '是否已解决',
                    value: 'isSolved'
                },
                {
                    label: '是否显示在首页',
                    value: 'isShowPage'
                },
                {
                    label: '是否已关闭',
                    value: 'isClose'
                },
                {
                    label: '是否公开',
                    value: 'isPublic'
                },
                {
                    label: '是否向专家提问',
                    value: 'isAskExpert'
                }
            ]
        }
    },
    methods: methods,
    computed: {
        
    }
}
</script>

<style lang="stylus" scoped>
    .Question
        width 100%
        height 100%
        .table
            width 100%
            height 80%
            overflow scroll

</style>

